package game.metalmax.ui.common
{
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	
	
	import showtime.framework.manager.AssetManager;
	import showtime.framework.manager.StyleManager;
	import showtime.framework.manager.WindowManager;
	import showtime.framework.motion.eaze;
	import showtime.framework.ui.Label;
	import showtime.framework.ui.Window;

	public class AlertWindow extends Window
	{
		private var contentLab:Label = null;
		
		private var closeBtn:Button002 = null;
		
		public function AlertWindow()
		{
		
		}
		
		override protected function initialize():void
		{
			super.initialize();
			addEventListener(MouseEvent.CLICK, clickHandler);
			size(310, 120);
		}
		
		override protected function createChildren():void
		{
			var window:Sprite = new (AssetManager.getInstance().getClass("MAIN_SPRITE_MAIN_WINDOW"));
			window.width = 310;
			window.height = 120;
			addChild(window);
			
			contentLab = new Label(this);
			contentLab.textField.defaultTextFormat = (StyleManager.getInstance().getStyleAsTextFormat("FONT_UI"));
			
			closeBtn = new Button002();
			closeBtn.move(285, 5);
			addChild(closeBtn);
		}
		
		override public function open():void
		{
			super.open();
		}
		
		override public function refresh(data:Object=null):void
		{
			setData(data);	
			contentLab.text = String(data);
		}
		
		override public function close():void
		{
			super.close();
			
			setData(null);
		}
		
		private function clickHandler(evt:MouseEvent):void
		{						
			if (evt.target == closeBtn)
			{
				eaze(this).to(0.2, {alpha:0}).onComplete(function():void{WindowManager.removePopUp(AlertWindow);});
				
			}
		}
	}
}